package cc.eddic.examinationsystem.web;

import cc.eddic.examinationsystem.core.BaseController;
import cc.eddic.examinationsystem.domain.Exam;
import cc.eddic.examinationsystem.domain.ExamQuestion;
import cc.eddic.examinationsystem.domain.Question;
import cc.eddic.examinationsystem.repository.ExamQuestionRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Slf4j
@Controller
@RequestMapping("/examquestion")
public class ExamQuestionController  extends BaseController {

    public ExamQuestionController(ExamQuestionRepository examQuestionRepository) {
        this.examQuestionRepository = examQuestionRepository;
    }

    @PostMapping("/paper")
    public String postQuestion(Model model){
        log.debug("1111");
        log.debug("model",model);
        List<ExamQuestion> examList = examQuestionRepository.findAll(); // 从数据库获取题目列表
        model.addAttribute("examList", examList); // 将题目列表传递到模板中
        return "exam"; // 返回题目列表模板页面
    }

    private final ExamQuestionRepository examQuestionRepository;


}
